import defaultSettings from '@/settings'

const { showSettings, fixedHeader, sidebarLogo } = defaultSettings
// console.log(showSettings) // undefined
// 知识点：对象.不存在的属性 值为undefined
// undefined->未定义，null值(是一个具体的值你得给它赋予null，他才能是null空值)

const state = {
  showSettings: showSettings, // 之前复杂模板里用过，但是作者忘记删除了(你可以帮助他沙坝村掉)
  fixedHeader: fixedHeader,
  sidebarLogo: sidebarLogo // 控制侧边栏导航-是否展示顶部logo
}

const mutations = {
  CHANGE_SETTING: (state, { key, value }) => {
    // eslint-disable-next-line no-prototype-builtins
    if (state.hasOwnProperty(key)) {
      state[key] = value
    }
  }
}

const actions = {
  changeSetting({ commit }, data) {
    commit('CHANGE_SETTING', data)
  }
}

export default {
  namespaced: true,
  state,
  mutations,
  actions
}

